package com.lx.idgenerator.autoconfigure;

import com.lx.generator.monitor.TpsThreshold;
import com.lx.idgenerator.segement.policy.IFetchPolicy;

import java.math.BigDecimal;

/**
 * 缓存id的默认策略
 * 缓存策略
 * @author wcy
 */
public class DefaultFetchPolicy implements IFetchPolicy {



    private TpsThreshold defaultTpsThreshold;
    public DefaultFetchPolicy(SegmentFetchProperties segmentFetchProperties) {
        this.defaultTpsThreshold = segmentFetchProperties.getDefaultQpsThreshold();
    }

    public DefaultFetchPolicy() {
    }

    @Override
    public Integer segmentFetchSize(String tag) {
        return defaultTpsThreshold.getNextSegmentFetchSize();
    }

    @Override
    public BigDecimal nextSegFetchPercent(String tag) {
        return defaultTpsThreshold.getNextSegmentFetchPercent();
    }

    @Override
    public void setTpsThreshold(String tag, Double tps) {
    }
}
